﻿#region Usings

using System.Data.Entity.ModelConfiguration;
using Rail.Net.Core.Model;

#endregion

namespace Rail.Net.Data.Configuration
{
    public class PriceDistanceMap : EntityTypeConfiguration<PriceDistance>
    {
        public PriceDistanceMap()
        {
            ToTable("PriceDistances");
            HasKey(priceDistance => priceDistance.Id);

            Property(priceDistance => priceDistance.TarifNumber).IsRequired();
            Property(priceDistance => priceDistance.Class).IsRequired().HasMaxLength(1);
            Property(priceDistance => priceDistance.ZoneFrom).IsRequired();
            Property(priceDistance => priceDistance.ZoneTo).IsRequired();
            Property(price => price.Price).IsRequired().HasPrecision(18, 2);
            Property(priceDistance => priceDistance.ValidFrom).IsRequired();
            Property(priceDistance => priceDistance.ValidTo).IsRequired();
            
            HasRequired(priceDistance => priceDistance.Ru).WithMany(ru => ru.PriceDistances);
        }
    }
}